import axios from '../utils/axios'
import request from 'axios'
import { ACCESS_TOKEN } from '../utils/config'

/**
 * 获取所有的题目
 * @returns 
 */
export const getAllSubjects = () => axios.get('/paper/getAllSubjects')

/**
 * 创建答卷
 * @param {*} data 
 * @returns 
 */
export const createPaper = (data) => axios.post('/paper/create', {data})

/**
 * 获取所有的答卷
 * @returns 
 */
export const getPaper = () => axios.get('/paper/getAll')

/**
 * 删除答卷
 * @param {*} id 
 * @returns 
 */
export const delPaper = (id) => axios.delete('/paper/delPaper/' + id)

/**
 * 获取一篇文章
 * @param {*} id 
 * @returns 
 */
export const getOnePaper = (id) => axios.get('/paper/getOnePaper/' + id)

/**
 * 添加题目
 * @param {*} optiosn 
 * @param {*} name 
 * @param {*} ans 
 * @param {*} score 
 */
export const addSubject = (data) => axios.post('/paper/addSubject', {data})

/**
 * 删除题目
 * @param {*} id 
 * @returns 
 */
export const delSubject = (id) => axios.delete('/paper/delSubject/' + id)

/**
 * 添加答题情况
 * @param {*} data 
 * @returns 
 */
export const addAnswer = (data) => axios.post('/paper/addAnswer', {data})

/**
 * 获取答题记录
 * @returns 
 */
export const getAnswer = () => axios.get('/paper/getAnswer')

/**
 * 获取答卷详情
 * @param {*} id 
 * @returns 
 */
export const getAnswerDetail = (id) => axios.get('/paper/getAnswerDetail/' + id)

/**
 * 获取题目记录
 * @returns 
 */
export const getSubjectRecord = () => axios.get('/paper/getSubjectRecord')


/**
 * 搜索题目
 * @param {*} w 
 * @returns 
 */
export const search = (w) => axios.get('/paper/search/' + w)

/**
 * 识别图片
 * @param {*} data 
 * @returns 
 */
export const searchImg = (data) => request.post('https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic?access_token=' + ACCESS_TOKEN , data, {
    headers: {
        "Content-Type": "application/x-www-form-urlencoded",
    }
})

/**
 * 获取学生的答卷
 * @returns 
 */
export const getStuPapers = () => axios.get('/paper/stuPapers')

/**
 * 获取练习题
 * @returns 
 */
export const getExec = (count) => axios.get('/paper/getExec/' + count)

/**
 * 获取所有试卷的名字
 * @returns 
 */
export const getPaperName = () => axios.get('/paper/getAllPaperName')

/**
 * 获取教师试卷数据详情
 * @param {*} paperId 
 * @returns 
 */
export const getTchData = (paperId) => axios.get('/paper/getTchDataAna/' + paperId)